﻿using DevExpress.XtraEditors;
using Lamex.Base;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lamex.mIE.Calculate
{
    public class LGC_VAL_BOM_P76
    {
        //"D、如果包含P76
        //根据[待维护物料号]抽出尺寸数据，表为[IE_Part_SizeParmList].[WIDTH]
        //IF [WIDTH]<=1200
        //   【P76_布板包装_W1200】=1
        //ELSE
        //   【P76_布板包装_W1201】=1
        //END IF"
        public static DataTable LGC_VAL_BOM_P76_VALUE(string DWG_No, string Part_No, string Process_Code, string WORKTIME_LOGIC_CODE,out string Error_Code)
        {
            string errorMsg = DWG_No + Part_No + Process_Code;
            Error_Code = "";
            try
            {
                
            DataTable dtFeature_List = Common.GetTable.GetTable_Feature();
            DataTable dtTemp = BaseBuildSql.GetDataTableBySql(" select WIDTH,HEIGHT FROM IE_Part_SizeParmList where PART_NO='" + Part_No + "'");
            if (dtTemp.Rows.Count > 0)
            {
                if (dtTemp.Rows[0]["WIDTH"].ToString().Trim().Length > 0 &&
                    dtTemp.Rows[0]["HEIGHT"].ToString().Trim().Length >0)
                {
                    if (Convert.ToDouble(dtTemp.Rows[0]["WIDTH"].ToString()) <= 1200 &&
                        Convert.ToDouble(dtTemp.Rows[0]["HEIGHT"].ToString())<=1200)
                    {
                        DataRow dr = dtFeature_List.NewRow();
                        dr["DWG_NO"] = DWG_No;
                        dr["PART_NO"] = Part_No;
                        dr["PROCESS_CODE"] = Process_Code;
                        dr["FEATURE_NAME"] = "P76_布板包装_W1200";
                        dr["FEAT_VALUE"] = 1;
                        dr["LABOR_VALUE"] = Calculate.LGC_TIM_VTA.LGC_TIM_VTA_VALUE(DWG_No, Part_No, "P76_布板包装_W1200", "", 1);//根据特征定义表工时字段计算
                        dr["UPDATE_TIME"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
                        dr["UPDATE_USER"] = Lamex.Common.Loginer.CurrentUser.AccountName;
                        dtFeature_List.Rows.Add(dr);
                    }
                    else
                    {
                        DataRow dr = dtFeature_List.NewRow();
                        dr["DWG_NO"] = DWG_No;
                        dr["PART_NO"] = Part_No;
                        dr["PROCESS_CODE"] = Process_Code;
                        dr["FEATURE_NAME"] = "P76_布板包装_W1201";
                        dr["FEAT_VALUE"] = 1;
                        dr["LABOR_VALUE"] = Calculate.LGC_TIM_VTA.LGC_TIM_VTA_VALUE(DWG_No, Part_No, "P76_布板包装_W1201", "", 1);//根据特征定义表工时字段计算
                        dr["UPDATE_TIME"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
                        dr["UPDATE_USER"] = Lamex.Common.Loginer.CurrentUser.AccountName;
                        dtFeature_List.Rows.Add(dr);
                    }
                }
                else
                {
                    Error_Code = "该号码尺寸参数表【长或宽】无数值！";
                }
            }
            else
            {
                Error_Code = "该号码尺寸参数表【长或宽】无数值！";
            }
            return dtFeature_List;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(errorMsg + ex.Message);
                return null;
            }
        }
    }
}
